package com.lsc.learn.mybatisplus.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lsc.learn.mybatisplus.mapper.UserMapper;
import com.lsc.learn.mybatisplus.pojo.User;


@RestController
@RequestMapping("/user")
public class UserController {
	
	@Autowired
	UserMapper userMapper;
	

	@GetMapping("/list")
	private Object list(String name) {
//		QueryWrapper<User> query = new QueryWrapper<>();
		LambdaQueryWrapper<User> query = Wrappers.lambdaQuery();
//		query.gt(User::getAge, "20");
		query.like(User::getName, "1");
		query.select();
//		query.like(StringUtils.isNotBlank(name), User::getName, name);
//		return userMapper.selectList(query);
		
		Page<User> page = new Page<>(1, 10);
		
		return userMapper.selectPage(page, query);
		
		
	}
	
}
